package demo.wrapper;

import java.util.Collections;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by zhangyanfei on 2018/4/8.
 * 01 || 10 = 11        01&11==01  10&11==10     判断是否需要wrapper
 * @author zhangyanfei
 * @date 2018/04/08
 */
public abstract class AbstractFatRmaWrapper {
    private static final Logger logger = LoggerFactory.getLogger(AbstractFatRmaWrapper.class);

    /**
     * 标识
     */
    public abstract FatRmaResultScope getScope();

    /**
     * wrapper 给子类去实现
     */
    abstract List<FatRma> doWrapper(List<FatRma> fatRmas);

    public List<FatRma> wrapper(List<FatRma> fatRmas, FatRmaResultScope resultScope) {
        if (getScope().isExtended(resultScope)) {
            try {
                fatRmas = doWrapper(fatRmas);
            } catch (Exception e) {

            }
        }
        return fatRmas;
    }

    public FatRma wrapper(FatRma fatRma, FatRmaResultScope resultScope) {
        if (getScope().isExtended(resultScope)) {
            try {
                fatRma = doWrapper(Collections.singletonList(fatRma)).get(0);
            } catch (Exception e) {

            }
        }
        return fatRma;
    }
}
